package loppy.utils
{
  public class MathUtils
  {
    public static const PI    :Number = Math.PI;
    public static const TWO_PI:Number = PI * 2.0;
    public static const PI_2  :Number = PI / 2.0;
    public static const PI_3  :Number = PI / 3.0;
    public static const PI_4  :Number = PI / 4.0;
    public static const PI_5  :Number = PI / 5.0;
    public static const PI_6  :Number = PI / 6.0;
    public static const PI_7  :Number = PI / 7.0;
    public static const PI_8  :Number = PI / 8.0;
    public static const DEGREE_TO_RADIAN:Number = PI / 180.0;
    public static const RADIAN_TO_DEGREE:Number = 180.0 / PI;
    
    public static function clamp(input:Number, lowerBound:Number, upperBound:Number):Number
    {
        if (input < lowerBound) return lowerBound;
        if (input > upperBound) return upperBound;
        return input;
    }
    
    public static function lerp(x1:Number, y1:Number, x2:Number, y2:Number, x3:Number):Number
    {
        return y1 - ((y1 - y2) * (x1 - x3) / (x1 - x2));
    }
  }
}
